package com.yvan.game.merge.support;

import io.swagger.annotations.ApiModel;
import lombok.val;

@ApiModel("返回操作结果")
public class ModelOps extends Model<Object> {

    public static ModelOps newSuccess() {
        val ops = new ModelOps();
        ops.setSuccess(true);
        ops.setMsg("操作成功");
        return ops;
    }

    public static ModelOps newSuccess(int rowAffect) {
        val ops = new ModelOps();
        ops.setSuccess(true);
        ops.setMsg("操作成功");
        ops.setData(rowAffect);
        return ops;
    }

    public static ModelOps newFail(String msg) {
        val ops = new ModelOps();
        ops.setSuccess(false);
        ops.setMsg(msg);
        return ops;
    }

    public static ModelOps newFail(String msg, Object data) {
        val ops = new ModelOps();
        ops.setSuccess(false);
        ops.setMsg(msg);
        ops.setData(data);
        return ops;
    }

    @Override
    public ModelOps setMsg(String msg) {
        return (ModelOps) super.setMsg(msg);
    }
}
